Using DXL to Run a VBA Macro on OLE object

I have imported a Word document with many tables into DOORS. Prior to the import, I converted all tables to OLE objects (Macro Enabled Word Files) and added a macro to each. I now need to loop through each of the OLE objects in DOORS and run the macro. I've seen a few discussions about DXL and VBA, but I'm having trouble getting started.

Things I don't know, but believe I need:

1. I need to identify if a DOORS object is a Word OLE (the module has a few image OLEs, and trying to run a non-existent macro in those would surely generate an error)

2. I may need to activate the Word OLE, and then run its only macro. Or I might be able to run the macro without activating/opening the OLE.

I'm doing this because DOORS appears to import all Word OLEs with Portrait page orientation. Thus, OLEs in my Word document with Landscape orientation end up in DOORS with Portrait orientation, which makes the table display incomplete.

Any help would be appreciated. (Using Word 12 and DOORS 9.5)

 

Abe


Abe H - Mon Apr 22 16:19:16 EDT 2013

Re: Using DXL to Run a VBA Macro on OLE object
GregM_dxler - Mon Apr 22 18:09:37 EDT 2013

Hi Abe,

Identifying and launching word can be done.  Not sure how to launch a macro but should be able to be done.

Greg


Attachments

WordApp1.dxl

Re: Using DXL to Run a VBA Macro on OLE object
llandale - Tue Apr 23 09:30:51 EDT 2013

Running a named Macro in your Word file looks like this:

  • OleAutoObj oaoWord   = get Application Handle
  • OleAutoArgs oaaArgs = create
  • clear oaaArgs
  • put  (oaaArgs, in_NameMacro)
  • oleMethod(oaoWord, "Run", oaaArgs)

I did not know that an "embedded word document" (OLE Diagram) was it's own "file" and could have it's own "macros".  In any case it sounds like all your OLE diagrams use the same Macro, in which case you wouldn't need to store that macro with each OLE.  I'm guessing the "in_NameMacro" above could indeed be the entire text of the macro instead of just a name of a macro in Word.

I may be wrong, but when you original create the OLE from the table you could do the following:

  1. Select and cut the table
  2. Paste-Special "Word Document Object"
  3. With the Word Document Object window open, adjust Page Layout to Landscape
  4. Adjust margins to fit the diagram
  5. Close the document object window
  6. Back in the main windows, adjust Page Layout to Landscape.

-Louie

Re: Using DXL to Run a VBA Macro on OLE object
Abe H - Tue Apr 23 15:02:18 EDT 2013

llandale - Tue Apr 23 09:30:51 EDT 2013

Running a named Macro in your Word file looks like this:

  • OleAutoObj oaoWord   = get Application Handle
  • OleAutoArgs oaaArgs = create
  • clear oaaArgs
  • put  (oaaArgs, in_NameMacro)
  • oleMethod(oaoWord, "Run", oaaArgs)

I did not know that an "embedded word document" (OLE Diagram) was it's own "file" and could have it's own "macros".  In any case it sounds like all your OLE diagrams use the same Macro, in which case you wouldn't need to store that macro with each OLE.  I'm guessing the "in_NameMacro" above could indeed be the entire text of the macro instead of just a name of a macro in Word.

I may be wrong, but when you original create the OLE from the table you could do the following:

  1. Select and cut the table
  2. Paste-Special "Word Document Object"
  3. With the Word Document Object window open, adjust Page Layout to Landscape
  4. Adjust margins to fit the diagram
  5. Close the document object window
  6. Back in the main windows, adjust Page Layout to Landscape.

-Louie

Louie,

I have DXL running the macro embedded in the OLE. And you're right about replacing in_NameMacro with the macro text, it works. I'm using ".isOle" to check if the object is OLE (which I believe I found in one of your other posts). This is great, thanks for the help.

DOORS still imports the OLE in Portrait page orientation no matter what I have set in the Word Document. I'm pretty sure the import code is resetting this.

 

Abe

Re: Using DXL to Run a VBA Macro on OLE object
KBSri - Tue May 29 06:56:18 EDT 2018

Abe H - Tue Apr 23 15:02:18 EDT 2013

Louie,

I have DXL running the macro embedded in the OLE. And you're right about replacing in_NameMacro with the macro text, it works. I'm using ".isOle" to check if the object is OLE (which I believe I found in one of your other posts). This is great, thanks for the help.

DOORS still imports the OLE in Portrait page orientation no matter what I have set in the Word Document. I'm pretty sure the import code is resetting this.

 

Abe

I need a help here, I tried running the VBA script with a named Macro I created called "isOLE"

My code is: 

Public Sub isOLE()
 

  • OleAutoObj oaoWord   = get Application Handle

 OleAutoArgs oaaArgs = create
 Clear oaaArgs()
 put  (oaaArgs, isOLE)
 oleMethod (oaoDoc, "Run", oaaArgs)
End Sub

Somehow I am getting an errors in the VBA code.